package com.webxiaohua.algorithm;

import java.util.Arrays;

/**
 * @author shenxinhua
 * @date 2019-06-30 16:42
 * @desc 全排列算法
 */
public class Lesson2 {
    public static void f1(int[] num,int i){
        if(i == num.length-1){
            System.out.println(Arrays.toString(num));
            return;
        }
        for(int j=i;j<num.length;j++){
            int t = num[i];
            num[i] = num[j];
            num[j] = t;
            f1(num,i+1);
            num[j] = num[i];
            num[i] = t;
        }
    }

    public static void main(String[] args){
        int[] num = {1,2,3,4};
        f1(num,0);
    }
}
